<%@ page language="java" import="java.util.*,java.sql.*,com.ruohi.util.dbutil.*,com.ruohi.util.common.*,com.ruohi.manage.*" pageEncoding="UTF-8"%><%
	Connection connection = null;
	DBHelper dbHelper = DBHelper.getInstance();
	Map model = new HashMap();
	Map enumMap = new TreeMap();
	String tableName = "gift_category_param";
	String channelUUID = CommonString.getFormatPara(request.getParameter("channel_uuid"));
	String category = CommonString.getFormatPara(request.getParameter("category"));
	Map adminInfo = (Map)session.getAttribute("adminInfo");
	try{
		connection = PoolManager.getConnection(DBType.getDBTypeByEnum("106013"));
		String id = CommonString.getFormatPara(request.getParameter("id"));
		if(null!=id&&!"".equals(id)){
			model = dbHelper.getMap(" select * from "+tableName+" where uuid = ? ",new Object [] {id} , connection);
		}
		if("".equals(channelUUID)&&null!=model){
			channelUUID = (String)model.get("channel_uuid");
		}
		
		String no = "";
		String name = "";
				
		List<Map> enumGiftList = (List)application.getAttribute("enumProductList");
		if(enumGiftList == null){
			enumGiftList = dbHelper.getMapList(" select no,name from service_common_enum_product where len(no) = 3 order by order_no desc,no asc  ");
			//application.setAttribute("enumGiftList",enumGiftList);
		}
		enumMap.put("","-请选择-");
		if(enumGiftList!=null){
			for(Map m : enumGiftList){
				no = (String)m.get("no");
				name = (String)m.get("name");
				name = CommonForm.getHtmlSpaceByString((String)m.get("parent_no"))+name;
				if(no.length()==4){
					enumMap.put(no,name);
				}
			}
		}
		no = CommonString.getFormatPara(model.get("no"));
		if("".equals(no)){
			no = Tools.getNo(category,tableName,"106013");
		}
		
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<title><%=Env.getInstance().getProperty("project_name") %></title>
	<link rel="stylesheet" type="text/css" href="/plugin/other/highslide/highslide.css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<link href="/backend/style/style.css" rel="stylesheet" type="text/css" />
	<script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" charset="utf-8" src="/plugin/editor/ueditor/editor_config.js"></script>
	<script type="text/javascript" charset="utf-8" src="/plugin/editor/ueditor/editor_all_min.js"></script>
	<link rel="stylesheet" type="text/css" href="/plugin/editor/ueditor/themes/default/ueditor.css"/>
	</head>

	<body style="margin: 0;padding: 0;">
    <form name="theform" id="theform" action="/backend/action/crud.jsp?enumNo=106013">
      <div class="formDiv">
        <div class="group"> <span><img src="/plugin/ui/ligerUI/ligerUI/skins/icons/communication.gif" /></span> <span class="groupTitle">基础信息</span> </div>
        <div class="formLeft"><span style="color:#F00">* </span>参数名称</div>
        <div class="formRight" style="width:190px">
          <input type="text" dataType="Require" msg="请输入参数名称" class="jr_text" name="zd_name" id="zd_name" value="<%=CommonString.getFormatPara(model.get("name")) %>" maxlength="50"/>
        </div>
        <div class="formLeft"><span style="color:#F00">* </span>参数编号(自动)</div>
        <div class="formRight" style="width:190px">
          <input type="text" name="zd_no" class="jr_text" readonly="readonly" id="zd_no" value="<%=no %>"/>
        </div>
		<div style="clear:left;"></div>
        <div class="formLeft">参数类型</div>
        <div class="formRight" style="width:190px"> 
       		<div class="jr_radio_group">
                <input type="radio" id="zd_type" name="zd_type" value="1" class="jr_radio" <%=!CommonString.getFormatPara(model.get("type")).equals("2")?"checked":""%> onclick="showEnum(1);"/>文本
                <input type="radio" id="zd_type" name="zd_type" value="2" class="jr_radio" <%=CommonString.getFormatPara(model.get("type")).equals("2")?"checked":""%> onclick="showEnum(2);"/>枚举 
            </div>       
        </div>
        <div class="formLeft" id="enumId1" >枚举选择</div>
        <div class="formRight" style='width:190px;' id="enumId2">
	        <select class="jr_select" name="zd_enum_no" id="zd_enum_no" style="width:150px;">
	        <%=CommonForm.createSelect(enumMap,CommonString.getFormatPara(model.get("enum_no"))) %>
	        </select>
	        <a href="javascript:jrWindow2('/backend/common_enum/product_common_enum_list.jsp','产品枚举管理',800,400);" >新增</a>
	    </div>
        <div style="clear:left;"></div>
        <div class="group"> <span><img src="/plugin/ui/ligerUI/ligerUI/skins/icons/communication.gif" /></span> <span class="groupTitle">扩展信息</span> </div>
        <div class="formLeft">规格参数</div>
        <div class="formRight" style="width:80px"> <%=CommonForm.createIsRadio(CommonString.getFormatPara(model.get("is_key")).equals("")?"0":CommonString.getFormatPara(model.get("is_key")),"zd_is_key") %> </div>
        </div>
        <div class="formLeft">搜索参数</div>
        <div class="formRight" style="width:80px"> <%=CommonForm.createIsRadio(CommonString.getFormatPara(model.get("is_search")).equals("")?"0":CommonString.getFormatPara(model.get("is_search")),"zd_is_search") %> </div>
        </div>
        <div class="formLeft">是否显示</div>
        <div class="formRight" style="width:80px"> <%=CommonForm.createIsRadio(CommonString.getFormatPara(model.get("is_show")),"zd_is_show") %> </div>
        </div>
        <div style="clear:left;"></div>
     </div>
      <input type="hidden" name="zd_order_no" id="zd_order_no" value="<%=CommonString.getFormatPara(model.get("order_no")) %>" />
      <input type="hidden" name="zd_parent_no" id="zd_parent_no" value="<%=CommonString.getFormatPara(model.get("parent_no")).equals("")?category:CommonString.getFormatPara(model.get("parent_no")) %>" />
      <input type="hidden" name="tableName" id="tableName" value="<%=tableName %>" />
      <input type="hidden" name="zd_id" id="zd_id" value="<%=CommonString.getFormatPara(model.get("id")) %>" />
      <input type="hidden" name="zd_channel_uuid" id="zd_channel_uuid" value="<%=channelUUID %>" />
    </form>
</body>
</html>
<script type="text/javascript" src="/plugin/jquery/jquery.form.js"></script>
<script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="/backend/scripts/common.js?tab" type="text/javascript"></script>
<script src="/plugin/validator/wofoshan/validator.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/plugin/other/highslide/highslide.min.js"></script>
<script type="text/javascript">
	function doSub(){
		var rs = Validator.Validate(document.getElementById("theform"),1);
		if(rs){
			jQuery("#theform").ajaxSubmit({
					type : "POST",
					async : false ,
					success : function(data) {
						var rs = parseInt(jQuery.trim(data), 10);
						if (rs > 0) {
							jrSuccess("保存成功！");
							<%
							if("".equals(id)){
								%>
							window.location.reload();
								<%
							}
							%>
						} 
					}
				});
		}
	}
	
	function showEnum(flag){
		if(flag==2){
			jQuery("#enumId1").css("display","block");
			jQuery("#enumId2").css("display","block");
		}else{
			jQuery("#enumId1").css("display","none");
			jQuery("#enumId2").css("display","none");	
		}
	}
	showEnum(<%=CommonString.getFormatPara(model.get("type"))%>);
	
	function jrWindow2(url, title, width, height, haveDel) {
		var btns = [];
		btns.push({
			text : '确定',
			onclick : function(item, dialog) {
				var rs = dialog.frame.doSub(dialog);
				var ifid;
				console.log('1111111111');
				if (typeof(parent.tab) != 'undefined') {
				console.log('2222222')
					ifid = parent.tab.getSelectedTabItemID();
					if (typeof(parent.document.getElementById(ifid).contentWindow.grid) != 'undefined') {
					console.log('33333333')
						parent.document.getElementById(ifid).contentWindow.grid.loadData();
					}
				}
				if (typeof(rs) != 'undefined' && rs == true) {
					dialog.close();
				}
			}
		});

		btns.push({
					text : '取消',
					onclick : function(item, dialog) {
						dialog.close();
					}
				});
		parent.nowDialog = window.parent.jQuery.ligerDialog.open({
					height : height,
					url : url,
					width : width,
					showMax : false,
					showToggle : false,
					showMin : false,
					isResize : false,
					modal : true,
					title : title,
					buttons : btns
				});
	}
	
</script>
<%
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		dbHelper.freeConnection(connection);
	}
%>